#include<bits/stdc++.h>
using namespace std;

struct node {
    string name;
    int val;
} a[10005];

signed main() {
    int n;
    cin >> n;

    double sum = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].name >> a[i].val;
        sum += a[i].val;
    }

    sum /= 2 * n;

    int idx;
    double delta = INT_MAX;
    for(int i = 1; i <= n; i++) {
        if(abs(a[i].val - sum) < delta) {
            delta = abs(a[i].val - sum);
            idx = i;
        }
    }
    cout << int(sum) << " " << a[idx].name;

    return 0;
}

